package project;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;

@SuppressWarnings("rawtypes")
public class Core {
	static ArrayList al1 = new ArrayList();//"Greg", "Craig", "David", "Behvean", "Scott"
	static ArrayList al2 = new ArrayList();//"Kim", "Ben", "Tim", "Scott", "Gary"

	public static void main(String[] args) {
		/*
		al1.add("GREG");
		al1.add("CRAIG");
		al1.add("DAVID");
		al1.add("BEHVEAN");
		al1.add("SCOTT");
		
		al2.add("KIM");
		al2.add("BEN");
		al2.add("TIM");
		al2.add("SCOTT");
		al2.add("GARY");
		
		HashSet hs1 = new HashSet();
		hs1.addAll(al1);
		hs1.addAll(al2);
		
		Iterator it1 = hs1.iterator();
		System.out.print("[");
		while(it1.hasNext())
		{
			System.out.print(it1.next());
			if(it1.hasNext())
			{
				System.out.print(", ");
			}
		}
		System.out.println("]");
		
		HashSet hs2 = new HashSet();
		hs2.addAll(al1);
		hs2.retainAll(al2);
		System.out.println(hs2);
		
		HashSet hs3 = new HashSet();
		hs3.addAll(hs1);
		hs3.removeAll(hs2);
		System.out.println(hs3);
		*/

		
		HashMap hm1 = new HashMap();
		hm1.put("GREG",27);
		hm1.put("CRAIG", 40);
		hm1.put("DAVID", 42);
		hm1.put("BEHVEAN", 45);
		hm1.put("SCOTT", 50);
		
		HashMap hm2 = new HashMap();
		hm2.put("KIM", 40);
		hm2.put("BEN", 32);
		hm2.put("TIM", 50);
		hm2.put("SCOTT", 33);
		hm2.put("GARY", 70);
		
		HashMap hmAll = new HashMap();
		hmAll.putAll(hm1);
		hmAll.putAll(hm2);
		System.out.println(hmAll);
		
		HashMap hm3 = new HashMap();
		hm3.putAll(hm1);
		Iterator it = hm2.keySet().iterator();
		while (it.hasNext()){
			Object temp = it.next();
			if (hm3.containsKey(temp)){
				hm3.put((temp+"1"), hm2.get(temp));
			}
			else{
				hm3.put(temp, hm2.get(temp));
			}
		}
		System.out.println(hm3);
		
		HashMap hm4 = new HashMap();
		hm4.put("SCOTT", 19);
		Iterator it1 = hm4.keySet().iterator();
		while (it1.hasNext()){
			Object temp = it1.next();
			if (hm3.containsKey(temp)){
				hm3.put((temp+"1"), hm4.get(temp));
        addToMap(temp, hm3.get(temp), hm3);         
      }
			else{
				hm3.put(temp, hm4.get(temp));
			}
		}
		System.out.println(hm3);
		
		
	}
	public static void addToMap(Object temp, Object value, HashMap hm3){
		if (hm3.containsKey(temp)){
				addToMap(temp + "1", value, hm3);
			}
			else{
				hm3.put(temp, value);
      //TODO
		//checks if key is in hashmap, keeps adding 1 until no collision, then adds key/value pair into hashmap
	}
}
/*
 * customall hashmap
 * addall x2
 * see what happens on 2xscott
 * 
 * 2.
 * add number to dupes
 * 
 * 3. add hashmap 3
 * has another scott, 19
 */